<!DOCTYPE html>
<html lang="en" class="no-js" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout" layout:decorator="layout">
<head>
<title>商品管理</title>
 <script th:inline="javascript">
/*<![CDATA[*/
    function add(event,element){
    	event.preventDefault();
    	var re = /^[0-9]+.?[0-9]*$/;
        var re2 =/^[0-9]*[1-9][0-9]*$/;


   		var _id = $(element).attr("href").split("_")[0];
   		var _limitNumber = $("#limitNumber"+_id).val();
   		var _credit = $("#credit"+_id).val();
   		var _money = $("#money"+_id).val();
   		var _creditType = $("#creditType"+_id).val();
   		var _isExchange = $("#isExchange"+_id).val();
   		var _spid = $(element).attr("href").split("_")[1];



   		if(_limitNumber==''){
   			alert("限购数量不能为空");return;
   		}
   		if(!re2.test(_limitNumber) && _limitNumber != 0){
   			alert("请输入正确的限购数量");return;
   		}
   		if(_credit==''){
   			alert("积分不能为空");return;
   		}
   		if(!re2.test(_credit)){
   			alert("请输入正确的积分");return;
   		}
        if(_credit.indexOf(".") >  -1) {
            alert("请输入正确的积分");return;
        }
   		if(_money==''){
   			alert("现金不能为空");return;
   		}
   		if($("#div_goods_grid:contains('现金')").length > 0){
            if(!re.test(_money)){
   			    alert("请输入正确的现金");return;
   		    }
        }

        var data = {idd:_id,limitNumberd:_limitNumber,creditd:_credit,moneyd:_money,creditTyped:_creditType,isExchanged:_isExchange,spidd:_spid,spadd:'spadd'};

        $.ajax({
          url: "/promotion/creditgoodsgoods/ajaxsave",
          cache: false,
          type:"post",
          data:data,
          success:function(result) {		//回调函数，result，返回值
              $("#div_creditgoodsgoods_grid").html(result);
          }
        });
    }

	
/*]]>*/
</script>
</head>
<body>
<div layout:fragment="content">
	<div class="row">
		<div class="col-md-12">
			<div class="btn-group pull-right">
				<a href="index.html" th:href="@{'/promotion/creditgoodsgoods/index/'+${creditGoodsId}}" id="sample_editable_1_new" class="btn green">返回<i class="fa fa-arrow-circle-o-left"></i></a>
			</div>
		</div>
	</div>
	<div class="row">
		<div class="col-md-12">
			<div class="form">
					<h4 class="form-section">商品信息</h4>
					
					<div class="form-body">
					<div class="col-md-15 col-sm-13">
						<form class="form-inline" th:action="@{'/promotion/creditgoodsgoods/list/'+${creditGoodsId}}"  th:object="${goodsSearch}"  method="post">
							<div class="form-group">
					            <select id="goodsBrandsId" name="goodsBrandsId" style="width:110px;" th:remove="none" class="form-control">
					            	<option value="">所有品牌</option>
					                <option th:each="eachValue : ${brands}" th:field="*{goodsBrandsId}" th:value="${eachValue.id}" th:text="${eachValue.name}"></option>
					            </select>	
					            <input type="hidden" id="hidden_goodsBrandsId" th:value="${goodsBrandsId}" />												
						</div>
							
							<div class="form-group">
					            <select id="goodsCategoryId" name="goodsCategoryId" style="width:110px;" th:remove="none" class="form-control">
					            	<option value="">所有分类</option>
					                <option th:each="eachValue : ${categorys}" th:field="*{goodsCategoryId}" th:value="${eachValue.id}" th:text="${eachValue.name}"></option>
					            </select>
					            <input type="hidden" id="hidden_goodsCategoryId" th:value="${goodsCategoryId}" />														
							</div>
		
							
							<div class="form-group">
							<label class="sr-only" for="keyword">keyword</label>
								<input type="text" name="keyword" style="width:80px;" th:field="*{keyword}" placeholder="关键字"  id="keyword" class="form-control" />
							</div>
	
							
							
							<button type="submit" id="bt_search" name="bt_search" class="btn green">
								<i class="fa  fa-search"></i>
							</button>
						</form>
					</div>
					
					
					</div>
					
			</div>
		</div>
	</div>
</div>	
</body>
</html>
